package com.ruoyi.web.controller.front;

import com.ruoyi.front.domain.*;
import com.ruoyi.front.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/front")
public class frontIndex {

    // 系统首页
    @GetMapping("/index")
    public String index(ModelMap mmap) {

        //图片
        List<SImage> images = getImge();
        mmap.put("images",images);

        //轮播图
        List<SBanner> bannerList = getBannerList(1);
        mmap.put("bannerList", bannerList);

        //导航菜单
        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);


        //文章
        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("product");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //合作机构
        SOrgContainer sOrgContainer = new SOrgContainer();
        List<SOrgContainer> containerlist = sOrgContainerService.selectSOrgContainerList(sOrgContainer);
        mmap.put("containerlist",containerlist);

        //联系我们
        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","index");


        return "front/index";
    }
    /**
     * @author  姜延鹏
     * @Description  关于我们
     * @param mmap
     * @date  2021/7/23
     * @return  java.lang.String

     */
    @GetMapping("/aboutus")
    public String aboutus(ModelMap mmap) {

        List<SImage> images = getImge();
        mmap.put("images",images);

        List<SBanner> bannerList = getBannerList(2);
        mmap.put("bannerList", bannerList);

        //联系我们
        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        //导航菜单
        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);


        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("aboutus");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","aboutus");

        return "front/aboutus";
    }
    /**
     * @author  姜延鹏
     * @Description  专业顾问
     * @param mmap
     * @date  2021/7/23
     * @return  java.lang.String

     */
    @GetMapping("/adviser")
    public String adviser(ModelMap mmap) {

        List<SImage> images = getImge();
        mmap.put("images",images);

        List<SBanner> bannerList = getBannerList(2);
        mmap.put("bannerList", bannerList);

        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);

        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("aboutus");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","aboutus");

        return "front/adviser";
    }
    /**
     * @author  姜延鹏
     * @Description  专业团队
     * @param mmap
     * @date  2021/7/23
     * @return  java.lang.String

     */
    @GetMapping("/team")
    public String team(ModelMap mmap) {

        List<SImage> images = getImge();
        mmap.put("images",images);

        List<SBanner> bannerList = getBannerList(2);
        mmap.put("bannerList", bannerList);

        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);

        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("aboutus");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","aboutus");

        return "front/team";
    }
    /**
     * @author  姜延鹏
     * @Description  业务介绍
     * @param mmap
     * @date  2021/7/23
     * @return  java.lang.String

     */
    @GetMapping("/product")
    public String product(ModelMap mmap) {

        List<SImage> images = getImge();
        mmap.put("images",images);

        List<SBanner> bannerList = getBannerList(3);
        mmap.put("bannerList", bannerList);

        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);

        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("product");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","product");

        return "front/product";
    }
    @GetMapping("/product2")
    public String product2(ModelMap mmap) {

        List<SImage> images = getImge();
        mmap.put("images",images);

        List<SBanner> bannerList = getBannerList(3);
        mmap.put("bannerList", bannerList);

        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);

        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("product");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","product");

        return "front/product-2";
    }
    @GetMapping("/product3")
    public String product3(ModelMap mmap) {

        List<SImage> images = getImge();
        mmap.put("images",images);

        List<SBanner> bannerList = getBannerList(3);
        mmap.put("bannerList", bannerList);

        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);

        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("product");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","product");

        return "front/product-3";
    }
    @GetMapping("/product4")
    public String product4(ModelMap mmap) {

        List<SImage> images = getImge();
        mmap.put("images",images);

        List<SBanner> bannerList = getBannerList(3);
        mmap.put("bannerList", bannerList);

        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);

        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("product");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","product");

        return "front/product-4";
    }

    /**
     * @author  姜延鹏
     * @Description  联系我们
     * @param mmap
     * @date  2021/7/23
     * @return  java.lang.String

     */
    @GetMapping("/contact")
    public String contactus(ModelMap mmap) {

        List<SImage> images = getImge();
        mmap.put("images",images);

        List<SBanner> bannerList = getBannerList(5);
        mmap.put("bannerList", bannerList);

        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);

        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("contact");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","contact");

        return "front/contact";
    }

    /**
     * @author  姜延鹏
     * @Description  职业发展
     * @param mmap
     * @date  2021/7/23
     * @return  java.lang.String

     */
    @GetMapping("/culture")
    public String culture(ModelMap mmap) {

        List<SImage> images = getImge();
        mmap.put("images",images);

        List<SBanner> bannerList = getBannerList(4);
        mmap.put("bannerList", bannerList);

        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);

        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("culture");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","culture");

        return "front/culture";
    }


    /**
     * @author  姜延鹏
     * @Description  求职招聘
     * @param mmap
     * @date  2021/7/23
     * @return  java.lang.String

     */
    @GetMapping("/job")
    public String job(ModelMap mmap) {

        List<SImage> images = getImge();
        mmap.put("images",images);

        List<SBanner> bannerList = getBannerList(4);
        mmap.put("bannerList", bannerList);

        SContactus contactus = getContact();
        mmap.put("contactus", contactus);

        List<SWebMenu> sWebMenus = getWebMenu();
        mmap.put("sWebMenus",sWebMenus);

        List<SWebMenu> sWebMenu = getWebMenuByTypeValue("culture");
        String infoId = sWebMenu.get(0).getId();

        SFeature sFeature = new SFeature();
        sFeature.setInfoId(infoId);
        List<SFeature> featurelist = sFeatureService.selectList(sFeature);
        mmap.put("featurelist",featurelist);

        //版权声明
        SCopyright copyright = getCopyright();
        mmap.put("copyright",copyright);

        mmap.put("target","culture");

        return "front/job";
    }



    public SContactus getContact(){
        SContactus sContactus = new SContactus();
        SContactus contactus = sContactusService.selectSContactusList(sContactus).get(0);
        return contactus;
    }

    public List<SBanner> getBannerList(Integer type){
        SBanner sBanner = new SBanner();
        sBanner.setType(type);
        List<SBanner> bannerList = sBannerService.selectList(sBanner);
        return bannerList;
    }

    public List<SWebMenu> getWebMenu(){
        SWebMenu sWebMenu = new SWebMenu();
        List<SWebMenu> sWebMenus = sWebMenuService.selectSWebMenuList(sWebMenu);
        return sWebMenus;
    }

    public List<SWebMenu> getWebMenuByTypeValue(String typeValue){
        SWebMenu sw = new SWebMenu();
        sw.setTypeValue(typeValue);
        List<SWebMenu> sWebMenu = sWebMenuService.selectSWebMenuList(sw);
        return sWebMenu;
    }

    public List<SImage> getImge(){
        SImage sImage = new SImage();
        List<SImage> list = sImageService.selectSImageList(sImage);
        return list;
    }

    public SCopyright getCopyright(){
        SCopyright sCopyright = new SCopyright();
        SCopyright copyright = sCopyrightService.selectSCopyrightList(sCopyright).get(0);
        return copyright;
    }


    @Autowired
    private ISBannerService sBannerService;
    @Autowired
    private ISFeatureService sFeatureService;
    @Autowired
    private ISOrgContainerService sOrgContainerService;
    @Autowired
    private ISContactusService sContactusService;
    @Autowired
    private ISWebMenuService sWebMenuService;
    @Autowired
    private ISImageService sImageService;
    @Autowired
    private ISCopyrightService sCopyrightService;
}
